package com.kaluli.project.repository.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Repository;

import com.kaluli.project.domain.entity.KllOrderSynApi;
import com.kaluli.project.domain.entity.KllProduct;
import com.kaluli.project.domain.entity.KllProductVo;
import com.kaluli.project.domain.repository.KllProductRepository;
import com.kaluli.system.repository.AbstractRepositorySupport;

@Repository
public class KllProductRepositoryImpl extends AbstractRepositorySupport<KllProductVo> implements KllProductRepository{

	@Override
	protected Class<KllProductVo> getEntityClass() {
		// TODO Auto-generated method stub
		return KllProductVo.class;
	}

	
	@Override
	public KllProductVo findById(String itemId) {
		StringBuffer sql = new StringBuffer("SELECT t.id,t.title,t.pic,t.price,t.discount_price AS discountPrice,t.intro,m.content,m.pic_detail AS picDetail,s.status as zt,s.status");
		sql.append(" FROM kll_item t ,kll_item_sku s,kll_item_attr m ");
		sql.append("  WHERE t.id=s.item_id AND m.item_id=t.id ");
		if(itemId!= null){
			sql.append(" and t.id="+itemId);
		}
		List<KllProductVo> list = excuteSql(sql.toString());
		KllProductVo main = null;
		if(list!=null&&list.size()>0){
			main =list.get(0);
		}
		return main;
	}
	

	
	

}
